/**
 * @author Halon
 */
function printObject(obj)
{
alert('Printing object:');
  var out = '';
  for (var p in obj)
  {
    out += p + ': ' + obj[p] + '\n';
  }
  alert(out);
}

function moveBlock(block, x, y,relativeBoolean) {
	var xx, yy;
	if(block.style) {
		xx = (block.style.left>block.clientLeft ? block.style.left : block.clientLeft);
		yy = (block.style.top>block.clientTop ? block.style.top : block.clientTop);
	} else {
		xx = block.clientLeft;
		yy = block.clientRight;
	}
	
    if(relativeBoolean) {
	    x += xx;
        y += yy;
    }
	
	if(block.style) {
		block.style.left = x;
		block.style.top = y;
	} else {
		block.left = x;
		block.top = y;
	}
}

function resizeBlock(block, wid, hei,relativeBoolean) {
	var xx, yy;
	if(block.style) {
		xx = (block.style.width>block.clientWidth ? block.style.width : block.clientWidth);
		yy = (block.style.height>block.clientHeight ? block.style.height : block.clientHeight);
	} else {
		xx = block.clientWidth;
		yy = block.clientHeight;
	}
	if(relativeBoolean) {
        wid += xx;
        hei += yy;
    }
    
	if(block.style) {
		block.style.width = wid;
		block.style.height = hei;
	} else {
		block.width = wid;
		block.height = hei;
	}
	
	/* alert('?!?!?!?!?!?!?!?!?!');
	alert(block.id);
	alert('wid, hei, cWid, cHei, wid_rel, hei_rel '+wid+' '+hei+' '+c_w+' '+c_h+' '+rel_w+' '+rel_h);
	printObject(block);
	printObject(block.style); */
}

function fixButton(but_id) {		// needed due to glitch with disappearing button text
	var block = document.getElementById(but_id);
	var c = block.clientWidth;
    block.children[1].style.width = block.clientWidth - 2*block.children[0].scrollWidth;
}

function copyElementById(id) {
    var ob = document.getElementById(id);
    var cop = ob.cloneNode(true);
    
    cop.children[1]["innerText"] += " kopia";
    
    moveBlock(cop,200,50,false);
    ob["parentElement"].appendChild(cop);
    return cop;
}

function copyElement(ob) {
    var cop = ob.cloneNode(true);
    
    cop.children[1]["innerText"] += " kopia";
    
    moveBlock(cop,200,50,false);
    ob["parentElement"].appendChild(cop);
    return cop;
}

function changeButtonText(ob,txt) {
    ob.children[1]["innerText"] = txt;
}        
   
   
CodeRepo.SetReady('Common');

